﻿@model Bordspil.Models.UserProfile


<div id="groups">

    <div class="group-name">    <img id = "ManagePicture" src='@Url.Action("GetAvatarByName", "Account", new { userName = Model.UserName })', alt="Notendamynd" />
    <h3>@Model.UserName</h3>
    <h3>Aldur: @Model.Age</h3>
    @if (Model.UserName == User.Identity.Name) {
        <p>Hei þetta ert þú ! komin til að skoða stigin þín ?</p>
    }
    else {
    <p>Vilt þú verða jafn góður og @Model.UserName ? Spilaðu nokkra leiki og mundu, <strong>æfingin skapar meistarann</strong></p>
    }
        <ul class="points">

        </ul>
    </div> 
    <div id="member-in-groups">
    <p>@Model.UserName er meðlimur í:</p>
    <ul id="member-in">

    </ul>
    </div>

</div>

<script>
    $(document).ready(function () {
        GetUserStuff();
        function GetUserStuff() {
            //ser um ad skila ollum gruppum sem notandi er i 
            var user = '@Model.UserName';
            $.ajax({
                type: "GET",
                corntentType: "application/json; charset=utf-8",
                url: "/Group/GetGroupsByUser",
                data: { "userName": user },
                dataType: "json",
                success: function (data) {
                   //console.log(data[0].GroupName);
                   for (var i in data) {
                       var gruppa = encodeURI(data[i].GroupName);
                     
                        $("#member-in").append("<li><a href=/Group/GroupProfile?groupName=" + gruppa + " >" + data[i].GroupName + "</li>");
                    }
                }
            });

            $.ajax({
                type: "GET",
                corntentType: "application/json; charset=utf-8",
                url: "/Highscore/GetUserPoints",
                data: { "userName": user },
                dataType: "json",
                success: function (svar) {
                    //skila stigum notanda ur ollum leikjum
                    //console.log(svar);
                    for (var i in svar) {
                        $(".points").append("<li><h4>Stig í " + svar[i].Games.GameName + "</h4>" + svar[i].UserOrGroupPoints + "</li>");
                    }
                }
            })
        }
    });
</script>


